package zen 
{
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import org.flixel.*;
	/**
	 * ...
	 * @author morgan
	 */
	public class ZenMountain extends FlxSprite
	{
		[Embed (source = "../../data/zen/mountain.png")] private var img_mountain:Class;
		
		public var time:Number = 0;
		public function ZenMountain(x:int, y:int) 
		{
			super(x, y, img_mountain);
			light(0);
		}
	
		public function light(sunAngle:Number):void
		{
			var reds:Array = [];
			var greens:Array = [];
			var blues:Array = [];
			var rgbArray:Array = []
			var zeroes:Array = []
			for (var i:int = 0; i < 256; i++)
			{
				var offAngle:Number = sunAngle - (i / 256 * Math.PI * 2);
				if (offAngle < -3.14159) { offAngle += 6.2818; }
				if (offAngle > 3.14159) { offAngle -= 6.2818; }
				var gray:Number = Math.abs((offAngle / 6.2818));
				gray = FlxU.bound(gray * 3, 0, 0.7);
				rgbArray.push(FlxU.makeColorFromHSB(21 + gray * 10, 0.61 - gray * 0.2, gray * 0.4 + 0.2, 0));
				zeroes.push(0);
			}
			framePixels.paletteMap(pixels, new Rectangle(0, 0, width, height), new Point(0, 0), rgbArray, zeroes, zeroes, null);
		}
		
		override public function update():void 
		{
			super.update();
			light(2.5 - (FlxG.state as ZenState).sun.x / 100);
		}
		
	}

}